﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Products;
using MinhTuan;
public partial class admin_order_orderdetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        String[] admin = Session["Admin"].ToString().Split(',');
        int id = int.Parse(admin[0].ToString());
        if (id < 0) Response.Redirect("http://localhost:2011/didong/admin/login.aspx");
        if (Request.QueryString["Id"] != null)
        {
            
            BinhData();
        }
    }
    protected void BinhData()
    {
        Int16 orderid=Convert.ToInt16(Request.QueryString["Id"].ToString());
        Orders order = Orders.Getorderdetail(orderid);
        if (order.Order_Id > 0)
        {
            porder.Visible = true;
            Psumit.Visible = true;

            Lid.Text = order.Order_Id.ToString();
            Litenkh.Text = order.Shipping_Name.ToString();
            Litotal.Text = order.Order_Total.ToString("0,0,0")+" vnđ";
            Liaddress.Text = order.Shipping_Address.ToString();
            lidt.Text = order.Shipping_Tel.ToString();
            Licty.Text = order.Shipping_City.ToString();
            Lisproducts.DataSource = SelectedList.GetSelectedItem(orderid);
            Lisproducts.DataBind();
        }
    }
    protected void Lisproducts_ItemDeleting(object sender, ListViewDeleteEventArgs e)
    {
        return;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Int16 id = Convert.ToInt16(Lid.Text);
        if (id != null)
        {
            
            bool result;
            result = Orders.Delete_Order(id);
            if (result == false)
            {
                this.lbmessage.Text = "Xoá không thành công";
            }
            else
            {
                this.lbmessage.Text = "Xoá thành công";
                porder.Visible = false;
                Psumit.Visible = false;
                this.Lisproducts.Visible = false;

            }

        }
    }
}
